export default {
  name: "newest",
  data() {
    return {
      // list:{
      //       title: '',
      //       insertdate: '',//发布时间
      //       accessoryid: '',//图片编码
      // },
      active: 1,
      sels: [], //选中的值显示 
      pagenum: 1,
      total: 0,
      list: [{
        title: '',
        context: '',
        insertdate: '',
        accessoryid: '',

      }],
    };
  },
  created() {
    this.geteData()
  },

  methods: {
    geteData() {
      this.loading = true
      let sendData = {
        pagenum: this.pagenum
      }
      this.$axios.$post('/system/v1/platform/action/list', sendData).then(res => {
        this.list = res.data.data.list
        this.loading = false;
        this.total = parseInt(res.data.data.totalnum)
        if (this.list) {
          this.loading = false;

        }
      })
    },
    //新增
    newAdd(obj) {
      this.$router.push({
        path: './newest/add',
        query: {
          active: 3,
          type: 'add',
          item: 7
        }
      })
    },

    //编辑
    edit(obj) {
      this.$router.push({
        path: './newest/add',
        query: {
          active: 2,
          actionid: obj,
          type: 'editor',
          item: 7

        }
      })
    },

    //详情
    details(obj) {
      this.$router.push({
        path: './newest/add',
        query: {
          active: 2,
          actionid: obj,
          type: 'newestDetails',
          item: 7
        },
      })
    },


    getImg() {

      this.imgurl = "data:image/jpeg;base64," + res.data.data.filecontent

    },
    toggleSelection(rows) {
      if (rows) {
        rows.forEach(row => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    //删除
    del(obj) {
      let sendData = {
        deleteid: [obj],
        type: "2"
      }
      this.$confirm('是否要删除该信息?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$axios.post("/app/v1/platform/problem/delete", sendData).then(res => {
          if (res.data.code === 1) {
            this.$message({
              type: 'success',
              message: '删除成功!'

            });
            this.geteData()
          }
        })
      }).catch(() => {
        this.$message({
          type: 'warning',
          message: '已取消删除'
        });
      });
    },
    //批量删除
    selsChange(val) {
      this.sels = val.map(item => {
        return item.actionid
      })
    },
    dels() {
      let sendData = {
        deleteid: this.sels,
        type: "2"
      }
      if (this.sels.length === 0) {
        this.$message.error({
          message: '没有勾选到数据',
        })
        return
      } else {
        this.$confirm('是否要批量删除信息?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() =>
          {
            this.$axios.post("/app/v1/platform/problem/delete", sendData).then(res => {
              if (res.data.code === 1) {
                this.$message({
                  type: 'success',
                  message: '删除成功!'
                });
              }
              this.geteData()
            })
          }).catch(() => {
          this.$message({
            type: 'warning',
            message: '已取消删除'
          });
        });
      }
    },

    //分页查询
    handleCurrentChange(val) {
      this.pagenum = val + '';
      this.geteData()
    },
  }
};